package org.ubc.cs410.disposal2020;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/* 
 * Map should be strictly used for storing preloaded maps we make.
 * Map-related data involved in game instances should instead go
 * into Game and Building.
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Map {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String name;

	@Persistent
	private String description;

	@Persistent
	private int totalGarbage; // default garbage on the entire map

	@Persistent
	private Float centerLatitude;

	@Persistent
	private Float centerLongitude;

	@Persistent
	private Integer zoomLevel;

	@Persistent(defaultFetchGroup = "true")
	private Set<BuildingBoundary> buildings;

	public Map(String name) {
		this.name = name;
	}

	public Map(String name, String description, Integer totalGarbage,
			Float centerLatitude, Float centerLongitude, Integer zoomLevel,
			Set<BuildingBoundary> buildings) {
		super();
		this.name = name;
		this.description = description;
		this.totalGarbage = totalGarbage;
		this.buildings = buildings;
		this.centerLatitude = centerLatitude;
		this.centerLongitude = centerLongitude;
		this.zoomLevel = zoomLevel;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getTotalGarbage() {
		return totalGarbage;
	}

	public void setTotalGarbage(int totalGarbage) {
		this.totalGarbage = totalGarbage;
	}

	public Long getId() {
		return id;
	}	

	public Float getCenterLatitude() {
		return centerLatitude;
	}

	public void setCenterLatitude(Float centerLatitude) {
		this.centerLatitude = centerLatitude;
	}

	public Float getCenterLongitude() {
		return centerLongitude;
	}

	public void setCenterLongitude(Float centerLongitude) {
		this.centerLongitude = centerLongitude;
	}

	public Integer getZoomLevel() {
		return zoomLevel;
	}

	public void setZoomLevel(Integer zoomLevel) {
		this.zoomLevel = zoomLevel;
	}

	public Set<BuildingBoundary> getBuildings() {
		return buildings;
	}

	public void setBuildings(Set<BuildingBoundary> buildings) {
		this.buildings = buildings;
	}

	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Rationale for Building ID numbers is as follows:
	 * First digit is location. At the moment, 1 = UBC.
	 * Second digit is boolean for whether or not it is a factory.
	 * Third and fourth are just numbers to differentiate
	 * them from other buildings in the same area as they are.
	 * 
	 * But that's just my reasoning. If you've got a better system, have at it.
	 */
}
